import config from '@/config';
import RequestBase from '@/utils/request.js';

const baseRequest = new RequestBase(config.equipment);
const req = new RequestBase(config.safetyUrl);

//设备台账详情
export function getDeviceStandingBookById(id) {
  return baseRequest.get(`/dfm/deviceLedger/v2/${id}`);
}

//设备台账详情by设备位号
export function getDeviceStandingBookByPoi(devicePositionNum) {
  return baseRequest.get(`/dfm/deviceLedger/getByDevicePositionNum/${devicePositionNum}`);
}

// 点检最新标准
export function getPointInspectStandard(id) {
  return baseRequest.get(`/dfm/spot/standard/device/${id}`);
}

// 点检全记录
export function getPointInspectRecord(id) {
  return baseRequest.get(`/dfm/spot/record/device?deviceId=${id}`);
}

// 润滑最新标准
export function getLubricationStandard(id) {
  return baseRequest.get(`/dfm/lubrication/device/${id}`);
}

// 润滑全记录
export function getLubricationRecord(id) {
  return baseRequest.get(`/dfm/lubrication/getDeviceRecordList?deviceId=${id}`);
}

// 维保最新标准
export function getMaintenanceStandard(id) {
  return baseRequest.get(`/dfm/maintenance/standard/device/${id}`);
}

// 维保全记录
export function getMaintenanceRecord(id) {
  return baseRequest.get(
    `/dfm/maintenance/task/getDeviceRecordList?deviceId=${id}`
  );
}

// 检修最新标准
export function getRepairStandard(id) {
  return baseRequest.get(`/dfm/overhaul/standard/device/${id}`);
}

// 检修全记录
export function getRepairRecord(id) {
  return baseRequest.get(`/dfm/overhaul/task/getTicketList?deviceId=${id}`);
}

/**
 * 获取设备绑定的安全附件
 */
export function getAccessoryById(deviceId) {
  return baseRequest.get(`/dfm/deviceLedger/accessory/${deviceId}`);
}

/**
 * 人员定位标签卡
 */
export function positionInfo(code) {
  return req.get(`/pvl/location-card/scanCode/${code}`);
}

/**
 * 当前登录用户是否有APP绑卡权限
 */
export function isAuthBind() {
  return req.get(`/pvl/location-card/check/permissions`);
}

// 解绑标签卡
export const unBindCard = (cardCode) => {
  return req.delete(`/pvl/location-card/un-bind/${cardCode}`)
}
// 绑定标签卡
export const bindCard = (data) => {
  return req.post('/pvl/location-card/bind', data)
}

// 运输介质
export function mediumList() {
  return req.get(`/pvl/location-card/getChemicalList`);
}

// 车辆类型
export const vehicleTypeList = (query = { keyword: '' }) => {
  return req.get(`/pvl/vehicle/vehicle-type/list/${query.keyword}`, { params: query })
}

/**
 * 当前登录用户是否有APP绑卡权限
 */
export function seqAndNfcConf() {
  return baseRequest.get(`/dfm/spot/plan/nfc-flag`);
}